home *** CD-ROM | disk | FTP | other *** search
/ MacWorld 1995 November / Macworld Nov ’95.toast / Developers / BoxMaker++ / BoxMaker++ ƒ / sources / standardgetfile.cp < prev   
Encoding:
Text File  |  1995-06-14  |  2.1 KB  |  95 lines  |  [TEXT/KAHL]

  1.  
  2. #include <Finder.h>
  3. #include <StandardFile.h>
  4.  
  5. #include "standardgetfile.h"
  6.  
  7. standardgetfile::standardgetfile( short dlogID,
  8.     OSType *thetypes, long numtypes, short *activelist)
  9.     : StandardFileReply()
  10.     , DLOG_ID( dlogID)
  11.     , activeList( activelist)
  12. {
  13.     setTypes( thetypes, numtypes);
  14. }
  15.  
  16. standardgetfile::~standardgetfile()
  17. {
  18.     delete theTypes;
  19. }
  20.  
  21. void standardgetfile::changeTypes( OSType *thetypes, long numtypes)
  22. {
  23.     delete theTypes;
  24.     setTypes( thetypes, numtypes);
  25. }
  26.  
  27. Boolean standardgetfile::doIt()
  28. {
  29.     Point where = { -1, -1};
  30.  
  31.     CustomGetFile(
  32.             theFileFilterUPP,
  33.             numTypes,
  34.             theTypes,
  35.             (StandardFileReply *)this,
  36.             DLOG_ID,
  37.             where,
  38.             theDlogHookUPP,
  39.             theModalFilterUPP,
  40.             activeList,
  41.             theActivateUPP,
  42.             (void *)this    // Ptr yourDataPtr
  43.     );
  44.     return sfGood;
  45. }
  46.  
  47. pascal Boolean theFileFilter( CInfoPBPtr myPB, Ptr myDataPtr)
  48. {
  49.     standardgetfile *it = (standardgetfile *)myDataPtr;
  50.     return it->filterThisItem( myPB);
  51. }
  52.  
  53. pascal short theDlogHook( short item, DialogPtr theDialog, Ptr myDataPtr)
  54. {
  55.     standardgetfile *it = (standardgetfile *)myDataPtr;
  56.     return it->handleItemPress( item, theDialog);
  57. }
  58.  
  59. pascal Boolean theModalFilter( DialogPtr theDialog,
  60.                                 const EventRecord *theEvent,
  61.                                 short *itemHit, Ptr myDataPtr)
  62. {
  63.     standardgetfile *it = (standardgetfile *)myDataPtr;
  64.     return it->filterEvent( theDialog, theEvent, itemHit);
  65. }
  66.  
  67. pascal void theActivate(
  68.     DialogPtr theDialog, short item, Boolean activating, Ptr myDataPtr)
  69. {
  70.     standardgetfile *it = (standardgetfile *)myDataPtr;
  71.     it->handleActivation( theDialog, item, activating);
  72. }
  73.  
  74. FileFilterYDUPP standardgetfile::theFileFilterUPP =
  75.                 NewFileFilterYDProc( theFileFilter);
  76.  
  77. DlgHookYDUPP standardgetfile::theDlogHookUPP =
  78.                 NewDlgHookYDProc( theDlogHook);
  79.  
  80. ModalFilterYDUPP standardgetfile::theModalFilterUPP =
  81.                 NewModalFilterYDProc( theModalFilter);
  82.  
  83. ActivateYDUPP standardgetfile::theActivateUPP =
  84.                 NewActivateYDProc( theActivate);
  85.  
  86. void standardgetfile::setTypes( OSType *thetypes, long numtypes)
  87. {
  88.     theTypes = new OSType[ numtypes];
  89.     numTypes = numtypes;
  90.     for( int i = 0; i < numtypes; i++)
  91.     {
  92.         theTypes[ i] = thetypes[ i];
  93.     }
  94. }
  95.